package com.ruoyi.api.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import com.ruoyi.api.interceptor.JwtInterceptor;

@Configuration
public class WebConfig implements WebMvcConfigurer {
 
	@Override
	public void addInterceptors(InterceptorRegistry registry) {
		//添加拦截器
    	registry.addInterceptor(new JwtInterceptor()).
    	excludePathPatterns("/api/user/login","/api/app/getVersions","/api/wx/login","/api/wx/payNotifyUrl","/api/alipay/payNotifyUrl",
    			"/api/health/**","/api/sleep/**","/api/qq/**","/api/user/register","/api/user/sendVerifyCode",
    			"/api/knowledge/info","/api/user/findPassword","/app/**","/api/third/**","/api/data/**")
    	.addPathPatterns("/api/**");//放掉某些特定不需要校验token的路由
	}
	
	@Override
	public void addResourceHandlers(ResourceHandlerRegistry registry) {
		// 将所有/static/** 访问都映射到classpath:/static/ 目录下
		registry.addResourceHandler("/app/img/**").addResourceLocations("file:/home/find/web/img/");
	}
}